package com.web.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.web.dao.UserInfoDao;
import com.web.dto.UserInfoDTO;
import com.web.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * @author zaneyang
 * @date 2020-10-19
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UserInfoServiceImpl implements UserInfoService {


    @Autowired
    UserInfoDao userInfoDao;
    /**
     * 唯一查询
     *
     * @param id 用户ID
     * @return UserInfo
     */
    @Override
    public UserInfoDTO findById(Long id) {

        return userInfoDao.findById(id);
    }

    /**
     * 分页查询
     *
     * @param pageNum 页码，第几页
     * @param pageSize 每页的记录数
     * @return 用户信息列表
     */
    @Override
    public PageInfo<UserInfoDTO> findByPage(Integer pageNum, Integer pageSize) {
        if(null == pageNum || null == pageSize ){
            return null;
        }
        PageHelper.startPage(pageNum,pageSize);
        
        return new PageInfo<>(userInfoDao.findByPage());
    }
}
